<?php require_once 'source.php';?>
<?php require_once 'config.php';?>
<?php require_once 'dao/dao_db.php';?>
<?php require_once 'dao/dao_checkin.php';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SYSTITLE?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div class="wrapper">
<?php require_once 'header.php';?>
<div id="layout">
	<div id="leftlay"><?php require_once 'leftnav.php';?></div>
	<div id="rightlay">
		<div class="columntitle"><?php echo CHECKIN?></div>
		<div class="columncontent">
			<div id="students">
			<div><input type="button" value="<?php echo REFRESH?>" style="padding:3px 15px;" onclick="javascript:location.reload();"/></div>
			<?php 
				if(isset($_SESSION['userid'])&&$_SESSION['level']==TEACHER){
				$result=get_online_num($_SESSION['userid']);
				$row=mysql_fetch_array($result);
			?>
			<div style="padding:15px 0;"><h4><?php echo ONLINENUM?>:<?php echo $row['ONLINENUMS']?></h4></div>
				<table>
					<tr>
						<th><?php echo USERNAME?></th>
						<th><?php echo STUDENDTID?></th>
						<th><?php echo LOGINTIME?></th>
						<th><?php echo STATUS?></th>
					</tr>
			<?php 
				$result=get_status_students($_SESSION['userid']);
				while($row=mysql_fetch_array($result)){
				if($row['STATUS']==ONLINE){
					$bgstyle='';
				}else{
					$bgstyle='background:#e9e9e9;color:#bbb;';
				}
			?>
					<tr style="<?php echo $bgstyle;?>">
						<td><?php echo $row['USERNAME']?></td>
						<td><?php echo $row['USERID']?></td>
						<td><?php if($row['LASTLOGIN']!=''){echo $row['LASTLOGIN'];}else{echo '';} ?></td>
						<td><?php if($row['STATUS']==ONLINE){echo ONLINEFLAG;}else{echo OFFLINEFLAG;} ?></td>						
					</tr>
			<?php }?>
				</table>
			<?php 
				}else{
					header("LOCATION:error.php?errcode=1");
				}
			?>			
			</div>
		</div>
	</div>
</div>
</div>
</body>
</html>
